Fix #1352 using magnolia macros #1952
Merged
+196
−64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main issue seems to be when using
Macro.anns
to inspect the annotations of parameters for Product types within therecurse
method. After taking a closer look at the code, it seems that we are unnecessarily double-extracting the parameter annotations for Product due to reusing the samerecurse
method for both Sum and Product types.With this PR, we use different recurse methods for Product and Sum types. This solves this issue since the parameter annotations are now extracted via
Macro.paramAnns
which works fine on JDK17+. To demonstrate, I added 2 unit tests for it and added test workflows for JDK17 for Scala 3 (also for Scala 2.13 for completeness).While the underlying issue with Magnolia still exists (see here), I think we should still do the separation as now macros that are specific to product/sum types are only executed when needed, which results in reduced compilation time + codegen size